<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
Option Explicit
Response.Buffer = True
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
Response.ContentType="text/html"
Response.Charset="gb2312"
Session.codepage=936
Dim Rs,Conn,sConnstr,sPath : sPath = "../../DataBases/global.mdb"
Call DBConnBegin(sPath)

'========================================================
'Database Connection Options
'========================================================
Function DbExists(Path,stype) 
        'On Error resume Next 
        Dim c : Set c = Server.CreateObject("ADODB.Connection")
		If stype=0 Then
		c.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Path
		Else 
        c.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(Path)
		End If
        If Err.number<>0 Then 
            Err.Clear 
            DbExists = false 
        else 
            DbExists = True 
        End If 
        set c = nothing 
End Function 
	
Sub DBConnBegin(Path)
	If IsObject(Conn) = True Then Exit Sub
	'On Error Resume Next
	sConnstr = "Provider=Microsoft.Jet.Oledb.4.0;Data Source="&Server.MapPath(Path) 
	Set Conn = Server.CreateObject("Adodb.Connection") 
	Conn.ConnectionString=sConnstr
	Conn.Open sConnstr
	If Err Then
		Err.Clear
		Conn.Close
		Response.Write("System Error!")
		Response.End()
	End If
	Set Rs=Server.CreateObject("Adodb.Recordset")
End Sub
	
Sub DBConnEnd()
	'On Error Resume Next
	Rs.Close : Set Rs = Nothing
	Conn.Close : Set Conn = Nothing
End Sub
%>
<!--#include file="../Global/md5.asp"-->
<!--#include file="../Global/AESCLS.asp"-->
<!--#include file="../Global/Function.asp"-->
<%
Dim sUserList,aUserList,n,sPwdList,aPwdList,SQL
sUserList="admin|System|DBAdmin|FileAdmin"
sPwdList="admin|admin|admin|admin"
aUserList=Split(sUserList,"|")
aPwdList=Split(sPwdList,"|")
Dim NextPass,AesCrypt,RndKey
For n=LBound(aUserList) To UBound(aUserList)
RndKey=RndChar(18)
'Response.Write "<br/>"&RndKey&"<br/>"
Set AesCrypt = New TAES
NextPass=AesCrypt.Encrypt(aPwdList(n),RndKey)
'Response.Write NextPass&"<br/>"
Set AesCrypt = Nothing
SQL="Update [Ruifox] Set UserPass='"&NextPass&"',LogonCode='"&RndKey&"' Where UserName='"&aUserList(n)&"'"
'Response.Write SQL&"<br/>"
Conn.Execute SQL
Next
SQL="SELECT ID FROM Channels"
Dim aChnlList,j
	Rs.Open SQL,Conn,1,1
	If Not Rs.Eof And Rs.Bof Then
		Response.Write("DataBase Error!")
	Else
		aChnlList=Rs.GetRows(,,Array("ID"))
	End If
	Rs.Close
	If IsArray(aChnlList) Then
		SQL="Delete From UserRight Where UserID=1"
		Conn.Execute SQL
		For j=Lbound(aChnlList,2) To UBound(aChnlList,2)
			SQL="Insert Into UserRight(UserID,ChnlID) Values(1,"&aChnlList(0,j)&")"
			Conn.Execute SQL
		Next
	End If
	Erase aChnlList
%>